package com.supcon.exchangedata.repository.slave4;

import com.supcon.exchangedata.pojo.entity.mysql.operation.gj.SgjjtBus;
import com.supcon.exchangedata.pojo.entity.mysql.operation.gj.SgjjtBusGps;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *  公交车
 * @Author: yangbin
 * @Date: 2022/04/20/9:00
 * @Description:
 */
public interface SlaveGjCarGpsInfo extends JpaRepository<SgjjtBusGps, Long> {
    @Transactional
    @Query(nativeQuery = true,value = "SELECT * FROM sgjjt_bus_gps where op = 'insert'")
    List<SgjjtBusGps> findAllBusCarStation();

    @Transactional
    @Query(nativeQuery = true,value = "SELECT * FROM sgjjt_bus_gps where recdatetime > ADDDATE(now(),interval -15 minute) and op = 'insert'")
    List<SgjjtBusGps> findCurrentBusCarStation();

    @Transactional
    @Query(nativeQuery = true,value = "SELECT * FROM sgjjt_bus_gps WHERE tongid=(SELECT MAX(tongid) from sgjjt_bus_gps)")
    SgjjtBusGps maxTongId();
}
